package com.smscenter.server.core.welink;

import com.smscenter.server.core.IExecutor;
import com.zeus.base.smscenter.common.constant.SmsConstants;
import com.zeus.base.smscenter.common.constant.WelinkConstants;
import com.zeus.base.smscenter.common.util.WebUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


/**
 * 短信发送类
 * @author: hailong
 * @date： 2016年10月19日
 *
 */
public class WelinkExecutor implements IExecutor {
	
	public static void main(String[] args) throws IOException {
		WelinkExecutor w = new WelinkExecutor();
		Map map = new HashMap();
		map.put("loginName", "dlherbfy");
		map.put("loginPassword", "Z0nbGe9y");
		map.put("phone", "15504607909");
		map.put("content", "订单发货喽!【飞扬软件】");
		map.put("bizNo", "4383080");
		System.out.println(w.excute(map));;
	}

    public String excute(Map<String, Object> params) throws IOException {
    	
    	//****************************短信发送*********************************
        String sname = (String) params.get("loginName");//用户姓名
        String spwd = (String) params.get("loginPassword");//用户密码
        String scorpid ="";//企业代码 可以为空
        String sprdid = WelinkConstants.SPRDID;//产品编号 写死
        String sdst = (String) params.get("phone");//接收号码 逗号间隔 
        String smsg = (String) params.get("content");//发送内容
        String skey = (String) params.get("bizNo");//唯一ID

        Map<String,String> requestMap=new HashMap<String, String>();
        requestMap.put("sname",sname);
        requestMap.put("spwd",spwd);
        requestMap.put("sdst",sdst);
        requestMap.put("smsg",smsg);
        requestMap.put("scorpid",scorpid);
        requestMap.put("sprdid",sprdid);
        requestMap.put("key",skey);

        String rsp = WebUtils.doPost(WelinkConstants.SMS_URL,WebUtils.buildAllQuery(requestMap, SmsConstants.CHARSET_UTF8), SmsConstants.CHARSET_UTF8, 10000, 10000);
        return rsp;
    }
}
